package org.oslims.domain;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import com.google.gwt.validation.client.NotEmpty;
import com.google.gwt.validation.client.NotNull;

@Entity
public class Request extends AbstractBaseEntity {

	/**
	 * 
	 */
	private static final long serialVersionUID = -4100884451028661887L;

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	private Long id;

	private String code;

	@ManyToOne
	@JoinColumn(name = "CUSTOMER_FK")
	@NotNull
	private Customer requestor;

	@Temporal(TemporalType.TIMESTAMP)
	private Date deadline;

	@NotEmpty
	private String subject;

	@NotEmpty
	private String description;

	@NotEmpty
	private String state;

	@NotEmpty
	private String priority;

	@ManyToMany(mappedBy = "requests")
	private List<AbstractSample> samples = new ArrayList<AbstractSample>();

	@ManyToOne
	@JoinColumn(name = "LAB_RESPONSIBLE_FK")
	private LabResponsible labResponsible;

	@OneToMany(mappedBy = "request")
	private List<Report> reports = new ArrayList<Report>();

	@ManyToOne
	@JoinColumn(name = "LAB_MANAGER_FK")
	private LabManager releasedBy;

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public Customer getRequestor() {
		return requestor;
	}

	public void setRequestor(Customer requestor) {
		this.requestor = requestor;
	}

	public Date getDeadline() {
		return deadline;
	}

	public void setDeadline(Date deadline) {
		this.deadline = deadline;
	}

	public String getSubject() {
		return subject;
	}

	public void setSubject(String subject) {
		this.subject = subject;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public String getState() {
		return state;
	}

	public void setState(String state) {
		this.state = state;
	}

	public List<AbstractSample> getSamples() {
		return samples;
	}

	public void setSamples(List<AbstractSample> samples) {
		this.samples = samples;
	}

	public LabResponsible getLabResponsible() {
		return labResponsible;
	}

	public void setLabResponsible(LabResponsible labResponsible) {
		this.labResponsible = labResponsible;
	}

	public List<Report> getReports() {
		return reports;
	}

	public void setReports(List<Report> reports) {
		this.reports = reports;
	}

	public LabManager getReleasedBy() {
		return releasedBy;
	}

	public void setReleasedBy(LabManager releasedBy) {
		this.releasedBy = releasedBy;
	}

	public void setPriority(String priority) {
		this.priority = priority;
	}

	public String getPriority() {
		return priority;
	}

}
